package com.xinqi.modules.prepare.folder.manager;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xinqi.common.mybatis.data.service.BaseService;
import com.xinqi.modules.prepare.common.domain.PrepareBaseParam;
import com.xinqi.modules.prepare.folder.domain.PrepareFileFolderEntity;
import com.xinqi.modules.prepare.folder.dto.req.PrepareFileFolderQueryDTO;
import com.xinqi.modules.prepare.folder.dto.rsp.PrepareFileFolderResultDTO;
import com.xinqi.modules.prepare.prepare.enums.PrepareFileTypeEnum;
import com.xinqi.modules.prepare.prepare.enums.PrepareTypeEnum;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 备课区文件夹管理层
 *
 * @author: system
 * @date: 2023/03/19
 */
public interface PrepareFileFolderManager extends BaseService<PrepareFileFolderEntity> {

    /**
     * 自定义分页查询
     */
    Page<PrepareFileFolderResultDTO> findPage(Page<Object> page, PrepareFileFolderQueryDTO query);

    /**
     * 自定义列表查询
     */
    List<PrepareFileFolderResultDTO> findList(PrepareFileFolderQueryDTO query);

    /**
     * 根据id查询 备课区文件夹数据
     */
    PrepareFileFolderEntity findById(Long id);

    PrepareFileFolderEntity findDeletedById(Long id);

    /**
     * 根据id删除 备课区文件夹数据
     */
    @Transactional(rollbackFor = Exception.class)
    boolean deleteById(Long id);

    @Transactional(rollbackFor = Exception.class)
    PrepareFileFolderEntity insertFile(PrepareBaseParam obj, Long prepareId, Long folderPid);

    @Transactional(rollbackFor = Exception.class)
    PrepareFileFolderEntity insertFile(PrepareBaseParam obj, Long prepareId, Long folderPid, Boolean isAutoGenerateName);

    @Transactional(rollbackFor = Exception.class)
    PrepareFileFolderEntity updateFile(PrepareBaseParam obj, Long prepareId);

    @Transactional(rollbackFor = Exception.class)
    PrepareFileFolderEntity deleteFile(PrepareBaseParam entity, Long prepareId);

    Boolean isExistName(Long prepareId, PrepareTypeEnum type, String name, Long pid, PrepareFileTypeEnum fileType, Long oId);

    Long getMaxNum(Long prepareId, PrepareTypeEnum type, String name, Long pid, PrepareFileTypeEnum fileType);

    List<PrepareFileFolderEntity> findByPid(Long pid);

    void setChildrenPath(List<PrepareFileFolderEntity> list, Long pid, String path);

    @Transactional(rollbackFor = Exception.class)
    void move(PrepareFileFolderEntity source, Long targetPrepareId, Long targetPid);

    @Transactional(rollbackFor = Exception.class)
    void copy(PrepareFileFolderEntity source, Long targetPrepareId, Long targetPid);

    @Transactional(rollbackFor = Exception.class)
    void restore(Long refId, Long prepareId, PrepareTypeEnum type);

    @Transactional(rollbackFor = Exception.class)
    void deleteAllChild(PrepareFileFolderEntity entity);

    List<PrepareFileFolderEntity> findByIds(List<Long> ids);

    long fileSizeTotal(Long prepareId);
}
